<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			let colors = [];
			function load(){
				let xhr = new XMLHttpRequest;
				xhr.open("GET","color.xml",false);
				xhr.send();
				let data = xhr.responseXML;
				colors = data.querySelectorAll("color")
				let s=document.querySelector("select")
				for (let i = 0; i < colors.length; i++) {
					let name = colors[i].querySelector("name").innerHTML
					s.options[i]=new Option(name);	
				}
				let v= colors[0].querySelector("value").innerHTML
				document.body.setAttribute("style","background-color: "+v+";")	
			}
			function fun(){
				let index=document.querySelector("select").selectedIndex
				let v= colors[index].querySelector("value").innerHTML
				document.body.setAttribute("style","background-color: "+v+";")
			}
		</script>
	</head>
	<body onload="load()">
		请选择颜色：<select onchange="fun()"></select>
		
	</body>
</html>
